package com.fjrz.bbxwj.main.host.adpter

import android.widget.ImageView
import android.widget.LinearLayout
import com.blankj.utilcode.util.ConvertUtils
import com.blankj.utilcode.util.ScreenUtils
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.viewholder.BaseViewHolder
import com.fjrz.bbxwj.R
import com.module.lemlin.base.loadRoundImage

class ReportImageAdapter : BaseQuickAdapter<Any, BaseViewHolder>(R.layout.item_report_image) {
    init {
        addChildClickViewIds(R.id.ivReportDelete)
    }

    override fun convert(holder: BaseViewHolder, item: Any) {
        val ivReportImage = holder.getView<ImageView>(R.id.ivReportImage)
        val width = (ScreenUtils.getAppScreenWidth() - ConvertUtils.dp2px(60f)) / 3
        val layoutParams = ivReportImage.layoutParams.apply {
            this.width = width
            this.height = width
        }
        ivReportImage.layoutParams = layoutParams

        if (holder.layoutPosition == data.size - 1) {
            ivReportImage.setImageResource(R.mipmap.ic_17630)
        } else {
            ivReportImage.loadRoundImage(item, radius = ConvertUtils.dp2px(10f))
        }
        holder.setGone(R.id.ivReportDelete, holder.layoutPosition == data.size - 1)
    }
}